import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';

import {
  BaseResponse,
  TimestampsWrapper,
  PageResponse,
} from '@server/basic-dto';
import { CreateOrUpdateDictionaryTypeDto } from '@server/modules/dictionary/dto';

export class CreateSubscribeDto {
  @ApiProperty({
    description: 'Product Update, 1代表勾选',
    enum: [0, 1],
  })
  product: string;

  @ApiProperty({
    description: 'Blog Update, 1代表勾选',
    enum: [0, 1],
  })
  blog: string;

  @ApiProperty({
    description: '语种环境(字典id)',
    type: String,
  })
  locale: string;

  @ApiProperty({
    description: '邮箱',
    type: String,
  })
  email: string;
}

export class SubscribeTypeItem {
  @ApiProperty({
    description: '字典类型信息',
    type: CreateOrUpdateDictionaryTypeDto,
  })
  @Type(() => CreateOrUpdateDictionaryTypeDto)
  type: CreateOrUpdateDictionaryTypeDto;

  @ApiProperty({
    description: '字典名称',
    type: String,
  })
  name: string;

  @ApiProperty({
    description: '字典值',
    type: String,
  })
  value: string;
}

export class QuerySubscribeItem extends TimestampsWrapper {
  @ApiProperty({
    description: 'Product Update, 1代表勾选',
    type: Boolean,
  })
  product: boolean;

  @ApiProperty({
    description: 'Blog Update, 1代表勾选',
    type: Boolean,
  })
  blog: boolean;

  @ApiProperty({
    description: '邮箱',
    type: String,
  })
  mail: string;

  @ApiProperty({
    description: '字典信息',
    type: SubscribeTypeItem,
  })
  @Type(() => SubscribeTypeItem)
  dictionary: SubscribeTypeItem;
}

export class QuerySubscribeList extends PageResponse {
  @ApiProperty({
    description: '订阅列表',
    type: QuerySubscribeItem,
    isArray: true,
  })
  @Type(() => QuerySubscribeItem)
  dictionary: QuerySubscribeItem;
}

export class QuerySubscribeResponse extends BaseResponse {
  @ApiProperty({
    description: '列表分页信息',
    type: QuerySubscribeList,
  })
  @Type(() => QuerySubscribeList)
  data: QuerySubscribeList;
}
